﻿using MongoDB.Bson.Serialization.Attributes;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;

namespace AppSocketModel
{
    /// <summary>
    /// 车辆当前位置信息 数据模型
    /// </summary>
    /// 
    [BsonIgnoreExtraElements]
    public class GpsInfoDto
    {
        /// <summary>
        /// 设备IMEI
        /// </summary>
        public string Imei { get; set; }
         
        /// <summary>
        /// 硬件代码
        /// </summary>
        public string HardwareCode { set; get; }

        /// <summary>
        /// 手机号
        /// </summary>
        public string Phone { get; set; }

        /// <summary>
        /// 0:正常数据 1:设备未上线 2:设备已过期 3:设备离线
        /// </summary>
        public int? DeviceInfo { get; set; }
        /// <summary>
        /// 0:正常数据 1:设备未上线 2:设备已过期 3:设备离线 4:设备静止
        /// </summary>
        public int? DeviceInfoNew { get; set; }
        /// <summary>
        /// 设备定位时间
        /// </summary>
        public DateTime? GpsTime { get; set; }

        /// <summary>
        /// 平台收到设备上报位置数据时的系统时间
        /// </summary>
        public DateTime? SysTime { get; set; } 
        /// <summary>
        /// 设备与平台的最后通信时间
        /// </summary>
        public DateTime? HeartTime { get; set; }
    /// <summary>
    /// 当前服务器时间
    /// </summary>
    public DateTime? ServerTime { get; set; }
        /// <summary>
        /// 经度
        /// </summary>
        public double Lng { get; set; }

        /// <summary>
        /// 经度半球 E或W（东经或西经）
        /// </summary>
        public string LngHemi { get; set; }
        /// <summary>
        /// 纬度
        /// </summary>
        public double Lat { get; set; }

        /// <summary>
        /// 纬度半球，N或S（北纬或南纬）
        /// </summary>
        public string LatHemi { get; set; }
        /// <summary>
        /// 航向
        /// </summary>
        public double? Course { get; set; }
        /// <summary>
        /// 速度
        /// </summary>
        public double? Speed { get; set; } 
        /// <summary>
        /// 设备平台状态信息
        /// </summary>
        public string Status { get; set; }
        /// <summary>
        /// 支持ACC
        /// </summary>
        public int? Acc { get; set; }
        /// <summary>
        /// 该设备切换为当前状态已经过的时长(秒)
        /// </summary>
        public string AccSeconds { get; set; }
        /// <summary>
        /// 定位方式
        /// </summary>
        public string Location { get; set; } 
        /// <summary>
        /// 电池电压
        /// </summary>
        public float BatteryVoltage { set; get; } 
        /// <summary>
        /// 唤醒类型
        /// </summary>
        public string WakeUpType { set; get; }

        /// <summary>
        /// 设备类型
        /// </summary>
        public DeviceType deviceType { set; get; }

        /// <summary>
        /// 车辆ID
        /// </summary>
        public long? VehicleId { get; set; }
        /// <summary>
        /// 车牌号
        /// </summary>
        public string VehicleNo { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreateTime { get; set; }

        /// <summary>
        /// 修改时间
        /// </summary>
        public DateTime? ModifyTime { get; set; }

        /// <summary>
        /// 数据发送序号
        /// </summary>
        public int SendNo{get; set; }

        /// <summary>
        /// 数据帧长度
        /// </summary>
        public int Len { set; get; }

        /// <summary>
        /// 信号强度
        /// </summary>
        public int SingledBm { set; get; }


        /// <summary>
        /// UTC时间转换
        /// </summary>
        public GpsInfoDto ToUtcDateTime( )
        {
            if (GpsTime.HasValue)
                GpsTime = DateTime.SpecifyKind(GpsTime.Value, DateTimeKind.Utc);
            if (ServerTime.HasValue)
                ServerTime = DateTime.SpecifyKind(ServerTime.Value, DateTimeKind.Utc);
            if (SysTime.HasValue)
                SysTime = DateTime.SpecifyKind(SysTime.Value, DateTimeKind.Utc);
            if (HeartTime.HasValue)
                HeartTime = DateTime.SpecifyKind(HeartTime.Value, DateTimeKind.Utc);
            return this;
    }
        /// <summary>
        /// LocationDto类型转换
        /// </summary>
        /// <returns></returns>
        public LocationDto  GetLocationDto()
        {
            return new LocationDto
            {
                IMEI = Imei,
                Course = Course,
                Speed = Speed,
                Location = Location,
                BatteryVoltage = BatteryVoltage,
                WakeUpType = WakeUpType,
                deviceType = deviceType,
                GpsTime = GpsTime,
                Lat = Lat,
                LatHemi = LatHemi,
                Lng = Lng,
                LngHemi = LngHemi,
                SysTime = SysTime,
                SendNo = SendNo,
                Len = Len,
                SingledBm = SingledBm
            };
        }
    }
}
